package com.example.studywords.bean;

import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Ignore;
import androidx.room.Index;
import androidx.room.PrimaryKey;

/**
 * 记录单词与翻译的关系,一对多
 */
@Entity(tableName = "word_trans_relation",
        foreignKeys = {@ForeignKey(entity = WordBean.class,parentColumns = "wordId",childColumns = "childWordId",onDelete = ForeignKey.CASCADE),
                        @ForeignKey(entity = TranslateBean.class,parentColumns = "translationId",childColumns = "childTranslateId",onDelete = ForeignKey.CASCADE)},
        indices = {@Index(value = "childWordId"),@Index(value = "childTranslateId")})
public class WordTransRelationBean {
    public WordTransRelationBean() {
    }
    @Ignore
    public WordTransRelationBean(int childWordId, int childTranslateId) {
        this.childWordId = childWordId;
        this.childTranslateId = childTranslateId;
    }

    public int getRelationId() {
        return relationId;
    }

    public void setRelationId(int relationId) {
        this.relationId = relationId;
    }

    public int getChildWordId() {
        return childWordId;
    }

    public void setChildWordId(int childWordId) {
        this.childWordId = childWordId;
    }

    public int getChildTranslateId() {
        return childTranslateId;
    }

    public void setChildTranslateId(int childTranslateId) {
        this.childTranslateId = childTranslateId;
    }

    @PrimaryKey(autoGenerate = true)
    private int relationId;
    private int childWordId;
    private int childTranslateId;
}
